package demo.practice.leetcode_eveyday;

public class P485 {

    public int findMaxConsecutiveOnes(int[] nums) {

        int maxOnes = 0;

        int ones = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] == 1) {
                ones++;
            } else {
                maxOnes = maxOnes>ones?maxOnes:ones;
                ones = 0;
            }
        }
        maxOnes = maxOnes = maxOnes>ones?maxOnes:ones;
        return maxOnes;
    }
}
